import React from 'react'
import {useDispatch, useSelector} from 'react-redux';
import { incre } from '../../app/slices/zanSlice';

export default function ReactRedux() {
  //只获取点赞数的状态   use 使用 selector 选择器
  let state = useSelector(state => state.zan);
  //获取 dispatch 更新函数
  let dispatch = useDispatch();
  return (
    <div>
      点赞数: {state.value}
      <button onClick={() => {
        dispatch(incre(10));
      }}>新增</button>
    </div>
  )
}
